% incremental symnmf run
% by Sun Sibai

addpath('./jsonlab'); % using JSONLab (http://www.mathworks.com/matlabcentral/fileexchange/33381-jsonlab--a-toolbox-to-encode-decode-json-files-in-matlab-octave)

datas={'1080598.txt'};
clsts=[40];
%datas={'1080598.txt';'1141410.txt';'502309.txt';'1141261.txt'};
if (exist('out','dir')==0)
 mkdir('out');
end
for str=1:size(datas,1)
 str=cell2mat(datas(str));
 X=importfile(str);
 A=swloadsp(X);
 for c=clsts
  [IdxTree, ErrTree, FlowRec, History, IdxDict] = swincresym(A, c);
%  save(strcat('out/',str,'.c',sprintf('%d',c),'.IdxTree.txt'),'IdxTree','-ascii');
%  save(strcat('out/',str,'.c',sprintf('%d',c),'.ErrTree.txt'),'ErrTree','-ascii');
%  save(strcat('out/',str,'.c',sprintf('%d',c),'.FlowRec.txt'),'FlowRec','-ascii');
%  savejson('',History,strcat('out/',str,'.c',sprintf('%d',c),'.History.txt'));

  savejson('',IdxDict,strcat('out/',str,'.c',sprintf('%d',c),'.increment.IdxDict.json'));
  savejson('',History,strcat('out/',str,'.c',sprintf('%d',c),'.increment.History.json'));
 end
end
